<section class="title">
<?php if ($this->method == 'create'): ?>
	<h4><?php echo lang('escort_banner_create_title'); ?></h4>
<?php else: ?>
	<h4><?php echo sprintf(lang('escort_banner_edit_title'), $banner->title); ?></h4>
<?php endif; ?>
</section>

<section class="item">
	
<?php echo form_open_multipart(uri_string(), 'class="crud" '); ?>
<div class="form_inputs" id="news-form">

	<fieldset>
	
		<ul>
			<li class="even">
				<label for="user_added"><?php echo lang('escort_banner_user_label'); ?></label>
				<div class="input"><?php echo form_input('user_added', $banner->user_added, 'maxlength="100" id="user_added" readonly="readonly"'); ?></div>				
			</li>
			<li class="odd multi-column">
				<ul>
					<li>
						<label for="ads_zone_id"><?php echo lang('escort_ads_zone_zone_label'); ?> <span>*</span></label>
						<div class="input"><?php echo form_dropdown('ads_zone_id', $adsZones, $banner->ads_zone_id, 'id="ads-zone-domain"'); ?></div>
					</li>
					<li>
						<label for="ads_zone_id"><?php echo lang('escort_ads_zone_code_label'); ?> <span>*</span></label>
						<div class="input"><?php echo form_input('ads_zone_code', $banner->code, 'id="ads-zone-code" readonly="readonly"'); ?></div>
					</li>
				</ul>				
			</li>
			<li class="even">
				<label for="domain"><?php echo lang('escort_ads_zone_domain_label')?></label>
				<div class="input" id="ads-zone-domains">
				<?php
				if($adsZone){
					$siteIds = explode(',',$adsZone->site_ids);
					$ci = & get_instance();
					$selectedSiteIds = array();
					if($banner->site_ids){
						$selectedSiteIds = explode(',',$banner->site_ids);
					}
					foreach ($siteIds as $siteId){
						$checked = FALSE;
						if(in_array($siteId, $selectedSiteIds)){
							$checked = TRUE;
						}
						$site = $ci->site_entity->init('id',$siteId);
						echo form_checkbox('site_ids[]',$siteId, $checked, 'id="site_id_'.$siteId.'"');
						echo '<label for="site_id_'.$siteId.'">'.$site->domain.'</label>';
					}
				}
				?>
				</div>
			</li>
			<?php
			if($bannerCountryList){
				$i = 0;
				foreach ($bannerCountryList as $bannerCountry){
					$i++;
			?>
			<li class="odd multi-column">
				<ul>
					<li>
						<label for="country_id"><?php echo lang('escort_banner_country_label')?></label>
						<div class="input"><?php echo form_dropdown('country_id['.$i.']', array('0' => lang('escort_banner_all_label')) + getCountryData_ioc(), $bannerCountry->country_id, 'id="country_'.$i.'" class="country_select"' )?></div>
					</li>
					<li>
						<label for="country_id"><?php echo lang('escort_banner_region_label')?></label>
						<div class="input"><?php echo form_dropdown('state_id['.$i.']', array('0' => lang('escort_banner_all_label')) + getStateData_ioc($bannerCountry->country_id) , $bannerCountry->region_id, 'id="state_country_'.$i.'" class="state_select"' )?></div>
					</li>
					<li id="province_state_country_<?php echo $i?>_wrapper">
						<label for="province_id"><?php echo lang('escort_banner_province_label')?></label>
						<div class="input"><?php echo form_dropdown('province_id['.$i.']', array('0' => lang('escort_banner_all_label')) + getProvinceData_ioc($bannerCountry->country_id, $bannerCountry->region_id, $bannerCountry->province_id) , $bannerCountry->province_id, 'id="province_state_country_'.$i.'" class="province_state_select"' )?></div>
					</li>
					<li class="delete-domain">
					<?php echo anchor('#', lang('global:delete'), array('class'=>'btn red delete', 'onclick' => 'return deleteDomain(this)'))?>
					</li>
				</ul>
			</li>
			<?php
				}
			}else{ 
			?>
			<li class="even multi-column">
				<ul>
					<li>
						<label for="country_id"><?php echo lang('escort_banner_country_label')?></label>
						<div class="input"><?php echo form_dropdown('country_id[1]', array('0' => lang('escort_banner_all_label')) + getCountryData_ioc(), '', 'id="country_1" class="country_select"' )?></div>
					</li>
					<li>
						<label for="country_id"><?php echo lang('escort_banner_region_label')?></label>
						<div class="input"><?php echo form_dropdown('state_id[1]', array('0' => lang('escort_banner_all_label')) + getStateData_ioc(0) , '', 'id="state_country_1" class="state_select"' )?></div>
					</li>
					<li id="province_state_country_1_wrapper">
						<label for="country_id"><?php echo lang('escort_banner_province_label')?></label>
						<div class="input"><?php echo form_dropdown('province_id[1]', array('0' => lang('escort_banner_all_label')) + getProvinceData_ioc(0, 0, 0) , '', 'id="province_state_country_1" class="province_state_select"' )?></div>
					</li>
					<li class="delete-domain">
					<?php echo anchor('#', lang('global:delete'), array('class'=>'btn red delete', 'onclick' => 'return deleteDomain(this)'))?>
					</li>
				</ul>
			</li>
			<?php
			} 
			?>
			<div id="add-more-zone-wrapper">
			</div>
			<li class="odd">
				<?php echo anchor('#', lang('escort_banner_add_more_label'), array('class'=>'btn red', 'id' => 'add-more-zone')); ?>
			</li>
			<li class="even multi-column">
				<ul>
					<li>
						<label for="banner_type"><?php echo lang('escort_banner_banner_type_label') ?></label>
						<div class="input"><?php echo form_dropdown('banner_type', $typeList, $banner->banner_type, 'id="banner_type"')?></div>
					</li>
					<li>
						<?php echo form_checkbox('display_after_login', 1, $banner->display_after_login, 'id="display_after_login"')?><label for="display_after_login"><?php echo lang('escort_banner_display_after_login_label')?></label>
					</li>
				</ul>
			</li>
			<li class="odd" style="<?php echo ($banner->banner_type == "text")?'':'display:none'?>" id="text-banner">
				<label for="define_text"><?php echo lang('escort_banner_define_text_label')?></label>
				<div class="input"><?php echo form_input('define_text', $banner->define_text)?></div>
			</li>
			
			<li class="odd" style="<?php echo ($banner->banner_type == "image")?'':'display:none'?>" id="image-banner">
				<label for="image"><?php echo lang('escort_banner_image_label')?></label>
				<div class="input"><?php echo form_upload('image')?>
					<?php
					if($banner->image){
						if(isset($this->image_lib)){
							$this->image_lib->clear();
						}
						$config['image_library'] = 'gd2';
						$config['source_image'] = './uploads/default/files/banners/'.$banner->image;
						//$config['new_image'] = $banner->image;
						$config['create_thumb'] = TRUE;
						$config['maintain_ratio'] = TRUE;
						$config['width'] = 75;
						$config['height'] = 50;
						$this->load->library('image_lib', $config);
						$this->image_lib->resize();
						
						$imageData = $this->image_lib->explode_name($banner->image);
					?>
					<a href="#"></a>
					<a href="<?php echo site_url().'uploads/default/files/banners/'.$banner->image?>" class="cboxElement media-photo" target="_blank" rel="group">
						<img src="<?php echo site_url().'uploads/default/files/banners/'.$imageData['name'].'_thumb'.$imageData['ext'] ?>" />
					</a>
					<?php
					}
					?>
				</div>
			</li>
			
			<li class="odd" style="<?php echo ($banner->banner_type == "script")?'':'display:none'?>" id="script-banner">
				<label for="script"><?php echo lang('escort_banner_type_script')?></label>
				<div class="input"><?php echo form_textarea('script', $banner->script)?></div>
			</li>
			<li class="even">
				<label for="title"><?php echo lang('escort_banner_title_label')?></label>
				<div class="input"><?php echo form_input('title', $banner->title)?></div>
			</li>
			<li class="even">
				<label for="">&nbsp;</label>
				<div class="input">
					<?php echo form_radio('follow',1, $banner->follow, 'id="follow"')?>
					<label for="follow"><?php echo lang('escort_banner_follow_label')?></label>
					<?php echo form_radio('follow',0, !$banner->follow, 'id="nofollow"')?>
					<label for="nofollow"><?php echo lang('escort_banner_nofollow_label')?></label>
				</div>
			</li>
			<li class="even">
				<label for=""><?php echo lang('escort_banner_link_label')?></label>
				<div class="input">
					<?php echo form_input('link', $banner->link)?>
				</div>
			</li>
			<li class="odd multi-column">
				<ul>
					<li>
						<label for="width"><?php echo lang('escort_ads_zone_width_label') ?></label>
						<div class="input"><?php echo form_input('width',$banner->width, 'id="ads-zone-width" readonly="readonly"')?></div>
					</li>
					<li>
						<label for="height"><?php echo lang('escort_ads_zone_height_label') ?></label>
						<div class="input"><?php echo form_input('height', $banner->height, 'id="ads-zone-height" readonly="readonly"')?></div>
					</li>
				</ul>
			</li>
			<li>
				<label for="active"><?php echo lang('escort_banner_active_label')?></label>
				<div class="input"><?php echo form_checkbox('active', 1, $banner->active)?></div>
			</li>
		</ul>
	</fieldset>
</div>
<div class="buttons float-right padding-top">
<?php $this->load->view('admin/partials/buttons', array('buttons' => array('save', 'save_exit', 'cancel'))); ?>
</div>
<?php echo form_close(); ?>
</section>
<div id='confirm'>
	<div class='header'><span><?php echo lang('escort_confirm')?></span></div>
	<div class='message'><?php echo lang('escort_banner_delete_domain_message')?></div>
		<div class='buttons'>
		<div class='no simplemodal-close'><?php echo lang('escort_confirm_no')?></div><div class='yes'><?php echo lang('escort_confirm_yes')?></div>
	</div>
</div>